package com.example.AIstudy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.AIstudy.domain.FalseReason;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

@Mapper
public interface FalseReasonDao extends BaseMapper<FalseReason> {
    @Select("select * from falsereason where userID=#{userID}")
    List<FalseReason> findReasonByUserID(Integer userID);

    @Insert("INSERT INTO falsereason(userID,falseReason) " +
            "VALUES (#{userID},#{falseReason})")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id",
            keyColumn = "id", resultType = Integer.class, before = false)
    void insertReason(FalseReason falseReason);
}
